package cn.edu.zjut.medlinebackend.service.impl;

import cn.edu.zjut.medlinebackend.model.Favorite;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.edu.zjut.medlinebackend.model.Groupfile;
import cn.edu.zjut.medlinebackend.service.GroupfileService;
import cn.edu.zjut.medlinebackend.mapper.GroupfileMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
* @author 86136
* @description 针对表【groupfile】的数据库操作Service实现
* @createDate 2024-01-10 15:56:54
*/
@Service
public class GroupfileServiceImpl extends ServiceImpl<GroupfileMapper, Groupfile>
    implements GroupfileService{
    @Resource
    private GroupfileMapper groupfileMapper;

    @Override
    public boolean uploadGroupFile(String fileName, Integer userId,Integer groupId) {
        Groupfile groupfile = new Groupfile();
        groupfile.setUserid(userId);
        groupfile.setFilename(fileName);
        groupfile.setGroupid(groupId);
        groupfile.setIsdelete(0);
        int insert = groupfileMapper.insert(groupfile);
        return insert > 0;
    }

    public boolean deleteGroupFile(String fileName, Integer userId,Integer groupId) {
        return groupfileMapper.deleteGroupFile(fileName, userId,groupId);
    }

    public boolean seleteGroupFile(String fileName, Integer userId,Integer groupId) {
        Groupfile groupfile = groupfileMapper.seleteGroupFile(fileName, userId,groupId);
        return groupfile != null;
    }
}




